#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cctype>

using namespace std;

extern char* StringBuffer;
extern int StringBufferLength;

bool InsertDirectory( char* Target, char* Directory )
{
 if( strlen( Target ) + strlen( Directory ) >= StringBufferLength )
 { return false; }
 StringBuffer[0] = '\0';
 sprintf( StringBuffer, "%s/%s", Directory , Target );
 Target[0] = '\0';
 strcpy( Target, StringBuffer );
 StringBuffer[0] = '\0';
 return true;
}

bool CreateFilebase( char* Target, char* FileBase )
{
 Target[0] = '\0';
 strcpy( Target, FileBase );
 return true;
}

bool ConstructFilename( char* Target, char* Directory, char* FileBase, double time, char* Extension )
{
 Target[0] = '\0';
 sprintf( Target, "%s/%s_%3.8f.%s", Directory, FileBase, time, Extension );
 int i=0;
 bool Found = false;
 while( i < strlen( Target ) && !Found )
 { if( Target[i] != '.' ){ i++; }else{ Found = true; } }
 Target[i] = '_';
 return true;
}



